package storm.bolt;

import org.apache.storm.trident.operation.BaseFunction;
import org.apache.storm.trident.operation.TridentCollector;
import org.apache.storm.trident.tuple.TridentTuple;
import org.apache.storm.tuple.Values;

/**
 * Created by luoqifei on 2016/10/12.
 */
public class StormSplitFuntionDemo extends BaseFunction {
   // public class Split extends BaseFunction {
    //storm Split 类的源码就是如下：将字符串元组切片，发射回去。也就是过滤一下数据，拆分，又返回啦
   public void execute(TridentTuple tuple, TridentCollector collector) {
            String sentence = tuple.getString(0);
            for(String word: sentence.split(" ")) {
                collector.emit(new Values(word));
            }
        }
    }
